昨天嘗試安裝PHPCI失敗了...那開發PHP還有哪些可以使用的持續整合方案呢?
使用Jenkins的話,還要安裝Jenkins,這是一個通用的持續整合伺服器,設定有點複雜...如果使用phpUnderControl,他實際上是持續整合的老祖宗CruiseControl的一個AddOn,還要安裝CruiseControl的話,感覺也是有一點麻煩。所以還是來嘗試xinc,這是一個純PHP的持續整合方案,透過PEAR就可以安裝。
參考:
* https://code.google.com/p/xinc/
* https://code.google.com/p/xinc/wiki/DocumentationXinc2_2
* 安裝
基本上,按照文件的指示,利用pear就可以安裝好。
不過,安裝過程中,會出現一些套件狀態的問題,例如安裝git的pear套件:VersionControl_Git時,會提示這個套件的狀態是alpha,建議使用"channel://pear.php.net/VersionControl_Git-0.4.4"來安裝,這個時候就改一下要安裝的套件名稱,透過channel來安裝:
Feng-Hsu-Pingteki-MacBook-Air:xinc fillano$ sudo pear install channel://pear.php.net/VersionControl_Git-0.4.4
downloading VersionControl_Git-0.4.4.tgz ...
Starting to download VersionControl_Git-0.4.4.tgz (14,831 bytes)
.....done: 14,831 bytes
install ok: channel://pear.php.net/VersionControl_Git-0.4.4
就可以了。如果要安裝svn,也適用同樣的方法。
用pear安裝完後,需要執行安裝後進一步設定的script:
Feng-Hsu-Pingteki-MacBook-Air:no-debug-non-zts-20090626 fillano$ sudo pear run-scripts xinc/Xinc
Including external post-installation script "/usr/local/share/pear/Xinc/Postinstall/Nix.php" - any errors are in this script
Inclusion succeeded
running post-install script "Xinc_Postinstall_Nix_postinstall->init()"
init succeeded
1. Directory to keep the Xinc config files : /etc/xinc
2. Directory to keep the Xinc Projects and Status information : /var/xinc
3. Directory to keep the Xinc log files : /var/log
4. Directory to install the Xinc start/stop daemon : /etc/init.d
5. Directory for xinc`s temporary files : /tmp/xinc
6. Do you want to install the SimpleProject example : yes
7. Directory to install the Xinc web-application : /var/www/xinc
8. IP of Xinc web-application : 127.0.0.1
9. Port of Xinc web-application : 8080
1-9, 'all', 'abort', or Enter to continue:
這個時候,需要根據自己的系統,修改一下安裝路徑。
1. Directory to keep the Xinc config files : /etc/xinc
2. Directory to keep the Xinc Projects and Status information : /var/xinc
3. Directory to keep the Xinc log files : /var/log
4. Directory to install the Xinc start/stop daemon : /usr/sbin
5. Directory for xinc`s temporary files : /tmp/xinc
6. Do you want to install the SimpleProject example : yes
7. Directory to install the Xinc web-application : /Library/WebServer/Documents/xinc
8. IP of Xinc web-application : 127.0.0.1
9. Port of Xinc web-application : 8080
1-9, 'all', 'abort', or Enter to continue:
Successfully copied /usr/local/data/Xinc/xinc.ini.tpl to: /usr/local/data/Xinc/xinc.ini
Successfully copied /usr/local/data/Xinc/etc/xinc/* to: /private/etc/xinc
Successfully copied /usr/local/data/Xinc/examples/SimpleProject to: /private/var/xinc/projects
Successfully copied /usr/local/data/Xinc/web/.htaccess to: /Library/WebServer/Documents/xinc
Successfully copied /usr/local/data/Xinc/web/* to: /Library/WebServer/Documents/xinc
Successfully copied /usr/local/data/Xinc/scripts/xinc-uninstall to: /usr/local/bin/xinc-uninstall
Successfully copied /usr/local/data/Xinc/scripts/xinc-uninstall.php to: /usr/local/bin/xinc-uninstall.php
Xinc installation complete.
- Please include /private/etc/xinc/www.conf in your apache virtual hosts.
- Please enable mod-rewrite.
- To add projects to Xinc, copy the project xml to /private/etc/xinc/conf.d
- To start xinc execute: sudo /usr/sbin/xinc start
UNINSTALL instructions:
- pear uninstall xinc/Xinc
- run: /usr/local/bin/xinc-uninstall to cleanup installed files
[OK] Saved ini settings
Install scripts complete
不知道對不對,反正先嘗試一下,看起來世界一片美好,接下來依照他的建議,設定port based virtualhost,然後重新啟動apache httpd...靠,沒畫面:
仔細檢查了一下,發現他提供的工具也不能跑,這時把declare(encoding='utf8');註解到就沒事,不過即使cli工具跟daemon會動,沒畫面就是沒畫面。
error_log看到的錯誤訊息:
[Sun Oct 20 23:09:31 2013] [error] [client ::1] PHP Fatal error: Uncaught exception 'Exception' with message 'Cannot create empty xinc.ini.' in /usr/local/share/pear/Xinc/Ini.php:74\nStack trace:\n#0 /usr/local/share/pear/Xinc/Ini.php(46): Xinc_Ini->__construct()\n#1 /Library/WebServer/Documents/xinc/handler.php(23): Xinc_Ini::getInstance()\n#2 {main}\n thrown in /usr/local/share/pear/Xinc/Ini.php on line 74
追到Xinc/Ini.php看了一下:
private function __construct()
{
$ret = include_once 'PEAR/Config.php';
if (!$ret || !class_exists('PEAR_Config')) {
throw new Exception('Cannot load pear config');
}
$strIniDir = PEAR_Config::singleton()->get('data_dir')
. DIRECTORY_SEPARATOR . 'Xinc';
$this->strFileName = $strIniDir . DIRECTORY_SEPARATOR . 'xinc.ini';
if (file_exists($this->strFileName)) {
if (is_readable($this->strFileName)) {
$this->_ini = @parse_ini_file($this->strFileName, true);
if (!is_array($this->_ini)) {
$this->_ini = array();
}
} else {
throw new Exception('Cannot read xinc.ini, permission denied?');
}
} elseif ((!is_dir($strIniDir) && !mkdir($strIniDir, 0700, true))
|| !touch($this->strFileName)
) {
throw new Exception('Cannot create empty xinc.ini.');
} else {
$this->_ini = array();
}
}
這是一個為singleton寫的constructor,簡單說就是找不到xinc.ini,不過從cli工具是可以找到,而且讀寫都沒問題。稍微加工一下,讓exception印出xinc.ini的完整路徑,發現...跟cli環境的php路徑不一樣,看來是我的OSX安裝php時發生的問題。安裝的過程是透過console,如果console跟web的php環境不一致,難怪會出問題。
不過沒時間了,今天先試到這裡,明天繼續吧,該好好整治一下我的OSX裡面的PHP,這是陳年老案了...